< previous page page_335 next page >

Page 335
Because Visual Basic does not place any restrictions on the type of data you are passing, it is important that you understand exactly what needs to appear on the stack.
The stack entries for both the src and dest parameters must contain a memory address. In other words, these entries are pointers.
0335-01.gif
Figure T5-3:
Using the RtlMoveMemory function
The obvious way to set these parameters is to pass the values by reference. The sample code in the Pointers.vbp example on your CD illustrates this:
Dim myVar As Long

Private Sub Form_Load()
   myVar = 5
End Sub

Private Sub Command1_Click()
   Dim Y As Long
   Call RtlMoveMemory(Y, myVar, 4)
   Debug.Print "New value of Y: " & Y
End Sub
In this example, the function defines a variable Y, which will be loaded with the data from the myVar variable (which was initialized to a value of 5 in the form load event). Both Y and myVar are passed by reference, which means that the stack will contain the address of the two variables. As you can see in the figure, the RtlMoveMemory function can use the pointers to copy the data from one variable to the other. Note that the addresses used in the figure are for illustrative purposes only; the actual addresses that you see will differ.

 
< previous page page_335 next page >